package com.yh.homestay.controller;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Collection;


/**
 * 页面跳转Controller
 *
 * @author Administrator
 */
@Controller
public class PageController {

    @RequestMapping("/")
    //从前台页面获取staffId之后，查询结果并返回对象，前台页面通过data.staffId获取
    public String toIndex(ModelMap map) {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        String staffId = authentication.getName();
        map.addAttribute("staffId", staffId);
        return "index.html";
    }

    @RequestMapping("/login")
    public String login() {
        return "login.html";
    }


    @RequestMapping("/{page}")
    public String toPage(@PathVariable("page") String page) {
        return page;
    }

}
